package com.mjt.admin.exceptions;

import com.mjt.admin.model.RespBean;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;



/**
 * @author shkstart
 * @create 2021-10-27 13:56
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * @description 处理参数异常
     * @author 莫某人
     * @date 13:58 2021/10/27
     * @param e
     * @return {@link }
     **/
    @ExceptionHandler(ParamsException.class)
    @ResponseBody
    public RespBean paramExceptionHandler(ParamsException e){
        return RespBean.error(e.getMessage());
    }



    /**
     * @description 权限不够当问被拒绝
     * @author 莫某人
     * @date 17:15 2021/10/31
     * @param
     * @return {@link }
     **/
    @ExceptionHandler(AccessDeniedException.class)
    public String accessDeniedException(AccessDeniedException e){
        return "403";
    }












   /**
     * @description 处理其他异常
     * @author 莫某人
     * @date 14:02 2021/10/27
     * @param
     * @return {@link }
     **/
    //@ExceptionHandler(Exception.class)
    //@ResponseBody
    //public RespBean ExceptionHandler(Exception e){
    //    return RespBean.error(e.getMessage());
    //}














}
